In the field of numerical calculating using systems such as calculators, computers, and software, calculating square roots of numbers is a time consuming task, often requiring a great deal of memory. Calculating square roots is often required in systems in which relatively fast response times and compact size are demanded. For example, in a disc drive, in order to determine the velocity profile during a seek, the square root of a function of disc drive parameters is calculated. Traditional disc drives employ lookup tables having a relatively large set of values used during disc drive operation in order to implement traditional square root algorithms. The look-up tables consume a large amount of valuable non-volatile memory. In the disc drive industry, a continuing push exists to read and write data more quickly from and to the data storage disc. Additionally, as non-volatile memory may greatly increase the cost of a given system, square root calculators employing look-up tables are unsuitable in smaller applications where reduced circuit size and low cost is desirable or necessary.
Many traditional systems utilize fixed-point processors for numerical calculations. A fixed-point processor, or fixed-point microprocessor, is generally an integrated circuit that performs numerical calculations in which the decimal point is always in the same location; that is, there is no variation in precision. Stated another way, the number of bits allocated for the mantissa never changes. Systems that utilize a fixed-point processor are ill-suited for conventional iterative algorithms for calculating a square root.
One problem that arises with a fixed-point processor implementation of square root algorithms is overflow. During iterations of the square root algorithm, intermediate results require more than one register, even though the final answer will generally take up only one register. For example, the Newton-Raphson algorithm (shown below) employs an iterative process in which a seed value (U(0)) is selected and entered into the function to generate a subsequent value (U(1)). The Newton-Raphson function is generally given as:U(i)=½*(U(i−1)+X/U(i−1)),  (1)where “X” is the number for which the square root is required, U(i) is a subsequent estimate of the square root, and U(i−1) is a prior estimate of the square root. This algorithm is typically repeated until a minimum difference is achieved between U(i) and U(i−1). If this algorithm is implemented with a 16 bit fixed-point microprocessor, values of U(i) can be a 16 bit integer having an 8 bit fraction. Thus, the division step (X/U(i−1)) is more complicated than a single division as shown above. Specifically, to perform the single division may require multiple divisions utilizing more than one divisor stored in more than one register. Thus, processing speed is slowed down.
Another problem with prior approaches is the use of costly non-volatile memory. For example, in order to reduce the time required to generate a square root, typical systems employ look-up tables of “seed” values (e.g., U(0) above). The closer a seed value is to the final answer, the fewer number of iterations are required to generate the square root. As another example, in disc drive applications, look-up tables are employed to provide values related to spin velocity associated with radial distances from the center of the disc. As track density increases on discs, the look-up tables in disc drives increase. Look-up tables are stored in costly non-volatile memory and their use is a drawback of prior approaches. Also, extra overhead involved with looking up the values is cost effective only with high precision (e.g., 32 bit) square root computations, wherein the look-up overhead is small compared to the iteration time saved.
Another problem related to disc drives is the inability in current approaches to dynamically calculate an optimal deceleration during a seek operation. When the disc drive actuator head travels from one track to another, the head accelerates for a given time duration and decelerates for a given time duration. The time duration is based on the distance between two tracks. In prior approaches, one level of deceleration is calculated during manufacture based on the largest distance between two tracks. This level of deceleration is calculated so that the time to move from the first track to the second track is minimized. During runtime, this level of deceleration is undesirable for seeks involving two tracks that are closer than the largest distance. When two tracks used in a seek are relatively close, the acceleration profile is compressed in time, but the deceleration value is not adjusted for the closer tracks. This gives rise to sharp changes in current, resulting in undesirable excitations in resonancies.
Accordingly there is a need for a method and system for calculating square roots at runtime using a fixed-point microprocessor, which is faster than traditional approaches and requires less memory while achieving the same precision as traditional approaches.